function _defineProperty(a, t, e) {
    return t in a ? Object.defineProperty(a, t, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : a[t] = e, a;
}

var app = getApp();

Page({
    data: {
        saleWallpaper: [],
        ownerrecList: [],
        orderShowList: [],
        yuan_bouns: "",
        app_name: "",
        avatar: "",
        navH: 0,
        plusH: 0,
        num: 2,
        is_zan: !1,
        page: 1,
        lastPage: !1,
        loading: !1,
        wp_id: 0,
        wp_index: 0,
        onVideo: !1,
        videoPath: null,
        share_title: "",
        share_pic: "",
        find: "find"
    },
    showWppic: function(a) {
        console.log(a), a = a.currentTarget.dataset.index, wx.previewImage({
            urls: [ this.data.saleWallpaper[a].path ]
        });
    },
    loginAfter: function(a) {
        app.loginAfter(a);
    },
    loginCancel: function() {
        app.loginCancel();
    },
    getSaleWallpaper: function(t) {
        var e = this;
        e.data.loading = !0, app.util.request({
            url: "entry/wxapp/getSaleWallpaper",
            data: {
                page: e.data.page
            },
            success: function(a) {
                if ("function" == typeof t && t(), a.data.data.length < 1) return console.log("到底了"), 
                void (e.data.lastPage = !0);
                e.data.saleWallpaper = 1 == e.data.page ? a.data.data : e.data.saleWallpaper.concat(a.data.data), 
                e.setData({
                    saleWallpaper: e.data.saleWallpaper
                }), e.data.loading = !1;
            }
        });
    },
    getPosterPic: function(a) {
        var t = this, e = a.currentTarget.dataset.wp_id, o = a.currentTarget.dataset.wp_idx;
        app.globalData.userInfo ? (t.setData({
            btnDis: !0
        }), app.util.request({
            url: "entry/wxapp/getQrWallpaper",
            data: {
                wp_id: e
            },
            success: function(a) {
                wx.showLoading({
                    title: "加载中"
                }), wx.downloadFile({
                    url: a.data.data,
                    success: function(a) {
                        wx.hideLoading(), 200 === a.statusCode && (t.setData({
                            btnDis: !1
                        }), wx.saveImageToPhotosAlbum({
                            filePath: a.tempFilePath,
                            success: function(a) {
                                wx.setClipboardData({
                                    data: t.data.saleWallpaper[o].share_title,
                                    success: function(a) {
                                        wx.hideLoading(), wx.showModal({
                                            title: "系统提示",
                                            content: "海报和文案素材已保存",
                                            confirmColor: "#f43f6c",
                                            confirmText: "知道了",
                                            showCancel: !1,
                                            success: function(a) {}
                                        });
                                    },
                                    fail: function(a) {
                                        console.log(a);
                                    }
                                });
                            }
                        })), app.util.request({
                            url: "entry/wxapp/delTempFile",
                            success: function(a) {}
                        });
                    },
                    fail: function(a) {
                        wx.showToast({
                            title: "获取海报图失败",
                            icon: "none"
                        });
                    }
                });
            }
        })) : app.checkLogin();
    },
    zanSaleWallpaper: function(a) {
        var t = this;
        console.log(a);
        var e = a.currentTarget.dataset.index, a = a.currentTarget.dataset.wp_id;
        app.globalData.userInfo ? app.util.request({
            url: "entry/wxapp/ZanSaleWallpaper",
            data: {
                wp_id: a,
                index: e
            },
            success: function(a) {
                console.log("222", a.data), "" === (a = a.data).data ? (t.data.saleWallpaper[e].is_zan = !0, 
                t.onNorepeat()) : (6 <= t.data.saleWallpaper[e].zan_data.length && t.data.saleWallpaper[e].zan_data.splice(5, 1), 
                t.data.saleWallpaper[e].zan_data.unshift(a.data), t.data.saleWallpaper[e].zan_count = 1, 
                t.data.saleWallpaper[e].is_zan = !0), t.setData({
                    saleWallpaper: t.data.saleWallpaper
                });
            }
        }) : app.checkLogin();
    },
    onNorepeat: function(a) {
        wx.showToast({
            title: "你已经点过赞了",
            icon: "success"
        });
    },
    wachVideo: function(a) {
        console.log(a);
        var t = this, a = a.target.dataset.path;
        console.log("gugugu"), t.data.onVideo = !t.data.onVideo, t.setData({
            onVideo: t.data.onVideo,
            videoPath: a
        });
    },
    onLoad: function(a) {
        console.log("options", a), this.setData({
            navH: app.globalData.navHeight,
            app_name: app.globalData.setting.name,
            avatar: app.globalData.setting.logo
        }), this.thisNav(), this.getSaleWallpaper(), this.getOwnerrecList(), this.getOrderShow();
    },
    thisNav: function() {
        var e = this;
        app.util.request({
            url: "entry/wxapp/getBottomNav",
            showLoading: !1,
            success: function(a) {
                console.log(a.data.data);
                var t = a.data.data;
                void 0 !== t.list.length && t.list.length < 1 ? wx.setTabBarStyle({
                    color: t.color,
                    selectedColor: t.selectedColor,
                    backgroundColor: t.backgroundColor,
                    borderStyle: 2 == t.borderStyle ? "black" : "white",
                    fail: function(a) {
                        console.log(a);
                    }
                }) : (wx.hideTabBar(), e.setData({
                    tabBar: a.data.data,
                    "tabBar.thisurl": e.__route__
                }));
            }
        });
    },
    getOwnerrecList: function(e) {
        var o = this;
        o.data.loading = !0, app.util.request({
            url: "entry/wxapp/getOwnerrecList",
            data: {
                page: o.data.page
            },
            success: function(a) {
                if ("function" == typeof e && e(), a.data.data.length < 1) return console.log("到底了"), 
                void (o.data.lastPage = !0);
                o.data.ownerrecList = 1 == o.data.page ? a.data.data : o.data.ownerrecList.concat(a.data.data), 
                console.log(o.data.ownerrecList);
                for (var t = 0; t < o.data.ownerrecList.length; t++) console.log(t, o.data.ownerrecList[t]), 
                o.data.ownerrecList[t].short_title && (o.data.ownerrecList[t].showAllcontent = !1, 
                console.log(o.data.ownerrecList[t]));
                o.setData({
                    ownerrecList: o.data.ownerrecList
                }), o.data.loading = !1;
            }
        });
    },
    showGoodsPic: function(a) {
        console.log(a);
        var t = a.target.dataset.index, a = a.target.dataset.idx, a = this.data.ownerrecList[a];
        wx.previewImage({
            current: a.pics[t],
            urls: a.pics
        });
    },
    showGoodsPicc: function(a) {
        console.log(a);
        var t = a.target.dataset.index, a = a.target.dataset.idx, a = this.data.orderShowList[a];
        wx.previewImage({
            current: a.pics[t],
            urls: a.pics
        });
    },
    toGoodsPage: function(a) {
        console.log(a);
        var t = a.currentTarget.dataset.goods_id, e = a.currentTarget.dataset.source, o = a.currentTarget.dataset.from_uid, n = a.currentTarget.dataset.goods_sign;
        o && (app.globalData.from_uid = o), void 0 !== a.currentTarget.dataset.source ? (a = "&source=" + e, 
        e = "&from_uid=" + app.globalData.from_uid, n && (a += "&goods_sign=" + n), wx.navigateTo({
            url: "../goods/goods?goods_id=" + t + a + e + "&find=" + this.data.find
        })) : (n && (t += "&goods_sign=" + n), wx.navigateTo({
            url: "../goods/goods?goods_id=" + t
        }));
    },
    getOrderShow: function(e) {
        var o = this;
        o.data.loading = !0, app.util.request({
            url: "entry/wxapp/getOrderShow",
            data: {
                page: o.data.page
            },
            success: function(a) {
                if ("function" == typeof e && e(), a.data.data.length < 1) return console.log("到底了"), 
                void (o.data.lastPage = !0);
                o.data.orderShowList = 1 == o.data.page ? a.data.data : o.data.orderShowList.concat(a.data.data);
                for (var t = 0; t < o.data.orderShowList.length; t++) o.data.orderShowList[t].short_content && (o.data.orderShowList[t].showAllcontent = !1);
                o.setData({
                    orderShowList: o.data.orderShowList
                }), o.data.loading = !1, console.log("orderShow", o.data.orderShowList);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    confirmSmart: function() {
        app.confirmSmart(this);
    },
    hideSmart: function() {
        app.hideSmart(this);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.page = 1, this.data.lastPage = !1, this.getTabData(function() {
            wx.stopPullDownRefresh();
        });
    },
    onReachBottom: function() {
        if (!0 === this.data.lastPage || !0 === this.data.loading) return !1;
        this.data.page++, this.getTabData();
    },
    onShareAppMessage: function(a) {
        var t = this;
        "button" === a.from ? (console.log("分享", a.target.dataset.res), e = a.target.dataset.res, 
        t.setData({
            share: e,
            toIndex: !1
        })) : (o = [ {
            title: app.globalData.setting.share_title || "购物省钱，分享赚钱",
            img: app.globalData.setting.share_pic,
            id: ""
        } ], t.setData({
            share: o[0],
            toIndex: !0
        }), console.log("右上角转发", t.data.share));
        var e = void 0 !== app.globalData.userInfo.uid ? "?from_uid=" + app.globalData.userInfo.uid + "&goods_id=" + t.data.share.goods_id + "&from_act=share&source=" + t.data.share.source : "?goods_id=" + t.data.share.goods_id + "&source=" + t.data.share.source, o = void 0 !== app.globalData.userInfo.uid ? "?from_uid=" + app.globalData.userInfo.uid + "&from_act=share" : "";
        return {
            title: t.data.share.title,
            path: this.data.toIndex ? "/first_duoduoke/pages/index/index" + o : "/first_duoduoke/pages/goods/goods" + e,
            imageUrl: t.data.share.share_pic || t.data.share.img
        };
    },
    onChangePage: function(a) {
        console.log(a), (a = a.target.dataset.num) != this.data.num && (this.setData({
            num: a,
            saleWallpaper: !1,
            ownerrecList: !1,
            orderShowList: !1
        }), this.data.page = 1, this.data.lastPage = !1, this.getTabData());
    },
    getTabData: function(a) {
        var t = this;
        switch (parseInt(t.data.num)) {
          case 1:
            t.getOrderShow(a);
            break;

          case 2:
            t.getOwnerrecList(a);
            break;

          case 3:
            t.getSaleWallpaper(a);
        }
        console.log(parseInt(t.data.num));
    },
    goDryingList: function(a) {
        wx.navigateTo({
            url: "../dryinglist/dryinglist"
        });
    },
    showAllcontent: function(a) {
        console.log(a);
        var t = this, a = a.currentTarget.dataset.index;
        t.data.ownerrecList[a].showAllcontent = !t.data.ownerrecList[a].showAllcontent, 
        console.log(t.data.ownerrecList[a].showAllcontent);
        var e = "ownerrecList[" + a + "].showAllcontent";
        t.setData(_defineProperty({}, e, t.data.ownerrecList[a].showAllcontent));
    },
    showAllcontent_showorder: function(a) {
        console.log(a);
        var t = this, e = a.currentTarget.dataset.index;
        t.data.orderShowList[e].showAllcontent = !t.data.orderShowList[e].showAllcontent, 
        console.log(t.data.orderShowList[e].showAllcontent), a = "orderShowList[" + e + "].showAllcontent", 
        t.setData(_defineProperty({}, a, t.data.orderShowList[e].showAllcontent));
    },
    zanOrderShow: function(a) {
        var t = this;
        console.log(a);
        var e = a.currentTarget.dataset.index, o = a.currentTarget.dataset.s_id;
        app.globalData.userInfo ? (console.log("uid", app.globalData.userInfo), a = app.globalData.userInfo.uid, 
        t.data.orderShowList[e].uid != a ? app.util.request({
            url: "entry/wxapp/zanOrderShow",
            data: {
                s_id: o,
                index: e
            },
            success: function(a) {
                console.log("222", a.data), "" === (a = a.data).data ? (t.data.orderShowList[e].is_zan = !0, 
                t.onNorepeat()) : (6 <= t.data.orderShowList[e].zan_data.length && t.data.orderShowList[e].zan_data.splice(5, 1), 
                t.data.orderShowList[e].zan_data.unshift(a.data), t.data.orderShowList[e].zan_count = 1, 
                t.data.orderShowList[e].is_zan = !0), t.setData({
                    orderShowList: t.data.orderShowList
                }), console.log("点赞后数据变化", t.data.orderShowList);
            }
        }) : wx.showToast({
            icon: "none",
            title: "自己不能给自己点赞"
        })) : app.checkLogin();
    }
});